package com.sfh.cp.home.child;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sfh.cp.home.child.adapter.ContentAdapter;
import com.sfh.cp.mass.MassAddMessageActivity;
import com.sfh.cp.mass.pst.IPstNote;
import com.sfh.cp.mass.req.ReqPageNote;
import com.sfh.cp.util.look.LookActivity;
import com.sfh.lib.mvp.IPresenter;
import com.sfh.lib.mvp.service.LoaderService;

import java.util.Arrays;

import crm.sfh.server.entity.EContent;
import crm.sfh.server.entity.ENote;
import crm.sfh.server.entity.EUser;
import crm.sfh.server.entity.rsp.TPage;

/**
 * 首页-最新
 */

public class NewestFragment extends BaseChildNoteFragment implements IPstNote.IVNote {


    public static NewestFragment newFragment() {
        return new NewestFragment();
    }

    IPstNote pstNote;

    @Nullable
    @Override
    public IPresenter getPresenter() {
        if (pstNote == null) {
            pstNote = LoaderService.getService(IPstNote.class);
        }
        return pstNote;
    }

    @Override
    public void onRefreshUI() {

        nowPage = 1;
        ReqPageNote req = new ReqPageNote(nowPage);
        // 留言
        req.setOrder("-createdAt");
        pstNote.listPage(req);
    }

    @Override
    public void onLoadMoreUI() {

        nowPage += 1;
        ReqPageNote req = new ReqPageNote(nowPage);
        req.setOrder("-createdAt");
        pstNote.listPage(req);
    }


    @Override
    public void onSuccess(TPage<EContent> page) {
        success(page);
    }

    @Override
    public void onError(String error) {

        error("", error);
    }

    @Override
    public void onClickFabulous(View v, ENote contentType) {

        pstNote.updateFabulous(contentType);
    }

}
